package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 新增分类
     * @param category
     */
    @Insert("insert into category (id, type, name, sort, status, create_time, update_time, create_user, update_user) " +
            "values (#{id}, #{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    @AutoFill(OperationType.INSERT)
    void insert(Category category);

    /**
     * 分类分页查询
     * @param build
     * @return
     */
    List<Category> selectCatgory(Category build);

    /**
     * 启用/禁用分类
     * @param build
     */
    @AutoFill(OperationType.UPDATE)
    void update(Category build);

    @Delete("delete from category where id = #{id}")
    void deleteById(@Param("id") Long id);
}
